package com.etc;


import redis.clients.jedis.Jedis;

import java.util.HashMap;
import java.util.Map;




public class TestAPI {
    public static void main(String[] args) {
//        tring(字符串)
        Jedis jedis = new Jedis("192.168.66.71", 6379);
//        jedis.set("yu", "tr");
//        jedis.set("yu", "trdf");
//        jedis.set("yu", "1fdsf");

//        System.out.println(jedis.get("yu"));
//`         Hash数据类型
//        Map<String, String> map = new HashMap<>();
//        map.put("name","zhangsn");
//        map.put("age","zhan");
//        map.put("id","zhgsn");
//        jedis.hmset("person",map);
//        System.out.println(jedis.hgetAll("person"));
//        System.out.println(jedis.hmget("person","name"));

//      List类型
//        jedis.flushDB();
//        jedis.lpush("red", "rea", "ere");
//        jedis.lpushx("red", "Oracle");
//        jedis.lpushx("red", "spark");
//        System.out.println(jedis.lrange("red", 0, -1));
//      set类型
//        jedis.sadd("redr","qq");
//        jedis.sadd("redr","qq","ss");
//        jedis.sadd("redr","qq","ss","tt","ere");
//        Set<String> red =jedis.smembers("redr");
//        for (String s : red) {
//            System.out.println(s);
//        }
//        有序集合类型（map）
        jedis.zadd("kk",33,"wang");
        jedis.zadd("kk",66,"pp");
        jedis.zadd("kk",90,"jj");
        jedis.zadd("kk",1,"gg");
        jedis.zadd("kk",77,"ss");
        Map<Double,String> scoresMap =new HashMap<>();
        scoresMap.put(new Double(55),"ss");
        scoresMap.put(new Double(44),"oo");
        jedis.zadd("kk",scoresMap);
        System.out.println("按照分数从低到高"+jedis.zrange("kk",0,4));
        System.out.println("按照分数从高到低"+jedis.zrevrange("kk",0,-1));
        jedis.set("key","vlaue");
        jedis.expire("key1",3);
        System.out.println(jedis.get("key1"));
        }
}
